/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FormDPelanggan.java
 *
 * Created on Feb 2, 2011, 4:48:37 PM
 */

package juwita;

import config.DBConnection;
import java.sql.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.JOptionPane;
import javax.swing.table.TableColumn;


/**
 *
 * @author Abah
 */
public class FormDPelanggan extends javax.swing.JInternalFrame {

    private DefaultTableModel DftTabModeDiscPlg;
    private DefaultTableModel DftTabModePelanggan;
    java.sql.Connection conn = new DBConnection().connect();
    
    /** Creates new form FormDPelanggan */
    public FormDPelanggan() {
        initComponents();
        btnDiscEdit.setEnabled(false);        
        tbDiscPlg.getTableHeader().setReorderingAllowed(false);        
       
        tampilDataDiscPlg();
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnTengah = new javax.swing.JPanel();
        pnAtas = new javax.swing.JPanel();
        txtKdPelanggan = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtKet = new javax.swing.JTextArea();
        txtNmPelanggan = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txtDiscPrs = new javax.swing.JTextField();
        ckDiscBerlaku = new javax.swing.JCheckBox();
        txtDiscRp = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        btnDiscEdit = new javax.swing.JButton();
        btnInfo = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        pnShow = new javax.swing.JPanel();
        pnDiscPlg = new javax.swing.JPanel();
        spDiscPlg = new javax.swing.JScrollPane();
        tbDiscPlg = new javax.swing.JTable();
        pnSearchDiscPlg = new javax.swing.JPanel();
        btnDiscSearch = new javax.swing.JButton();
        btnDiscShowAll = new javax.swing.JButton();
        txtSrcDiscPlg = new javax.swing.JTextField();
        cbSrcDiscPlg = new javax.swing.JComboBox();
        infoDiscPlg = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));
        setClosable(true);
        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("Pengaturan Discount Pelanggan");
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/disc_pel.PNG"))); // NOI18N
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameClosing(evt);
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });

        pnTengah.setBackground(new java.awt.Color(255, 255, 255));
        pnTengah.setLayout(new java.awt.BorderLayout());

        pnAtas.setBackground(new java.awt.Color(255, 255, 255));
        pnAtas.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 255), 2));
        pnAtas.setPreferredSize(new java.awt.Dimension(410, 200));
        pnAtas.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        txtKdPelanggan.setEditable(false);
        txtKdPelanggan.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        pnAtas.add(txtKdPelanggan, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 10, 110, -1));

        jLabel2.setText("Kode Pelanggan");
        pnAtas.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, -1));

        jLabel4.setText("Keterangan");
        pnAtas.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 120, -1, -1));

        txtKet.setColumns(20);
        txtKet.setRows(5);
        jScrollPane1.setViewportView(txtKet);

        pnAtas.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 120, 240, 50));

        txtNmPelanggan.setEditable(false);
        pnAtas.add(txtNmPelanggan, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 40, 240, -1));

        jLabel5.setForeground(new java.awt.Color(0, 0, 204));
        jLabel5.setText("*pilih salah satu");
        pnAtas.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 70, -1, -1));

        jLabel6.setText("Discount %");
        pnAtas.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, -1, -1));

        txtDiscPrs.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtDiscPrs.setText("0");
        txtDiscPrs.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtDiscPrsFocusLost(evt);
            }
        });
        txtDiscPrs.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtDiscPrsKeyPressed(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDiscPrsKeyTyped(evt);
            }
        });
        pnAtas.add(txtDiscPrs, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 90, 40, -1));

        ckDiscBerlaku.setBackground(new java.awt.Color(255, 255, 255));
        ckDiscBerlaku.setText("Berlaku");
        pnAtas.add(ckDiscBerlaku, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 10, -1, -1));

        txtDiscRp.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtDiscRp.setText("0");
        txtDiscRp.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtDiscRpFocusLost(evt);
            }
        });
        txtDiscRp.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtDiscRpKeyPressed(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDiscRpKeyTyped(evt);
            }
        });
        pnAtas.add(txtDiscRp, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 90, 90, -1));

        jLabel7.setText("Discout Rp");
        pnAtas.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 90, -1, -1));

        btnDiscEdit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/btn_edit.png"))); // NOI18N
        btnDiscEdit.setText("Edit");
        btnDiscEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDiscEditActionPerformed(evt);
            }
        });
        pnAtas.add(btnDiscEdit, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 130, -1, 40));

        btnInfo.setText("?");
        btnInfo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnInfoActionPerformed(evt);
            }
        });
        pnAtas.add(btnInfo, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 90, 30, -1));

        jLabel8.setText("Nama Pelanggan");
        pnAtas.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, -1, -1));

        pnTengah.add(pnAtas, java.awt.BorderLayout.PAGE_START);

        pnShow.setLayout(new java.awt.CardLayout());

        pnDiscPlg.setLayout(new java.awt.BorderLayout());

        spDiscPlg.setAutoscrolls(true);

        tbDiscPlg.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tbDiscPlg.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        tbDiscPlg.setGridColor(new java.awt.Color(0, 0, 255));
        tbDiscPlg.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                tbDiscPlgMousePressed(evt);
            }
        });
        tbDiscPlg.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tbDiscPlgKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tbDiscPlgKeyReleased(evt);
            }
        });
        spDiscPlg.setViewportView(tbDiscPlg);

        pnDiscPlg.add(spDiscPlg, java.awt.BorderLayout.CENTER);

        pnSearchDiscPlg.setBackground(new java.awt.Color(255, 255, 255));
        pnSearchDiscPlg.setPreferredSize(new java.awt.Dimension(0, 70));
        pnSearchDiscPlg.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        btnDiscSearch.setText("Search");
        btnDiscSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDiscSearchActionPerformed(evt);
            }
        });
        pnSearchDiscPlg.add(btnDiscSearch, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 40, 80, -1));

        btnDiscShowAll.setText("Show All");
        btnDiscShowAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDiscShowAllActionPerformed(evt);
            }
        });
        pnSearchDiscPlg.add(btnDiscShowAll, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 10, 80, -1));
        pnSearchDiscPlg.add(txtSrcDiscPlg, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 40, 220, 20));

        cbSrcDiscPlg.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Kode Disc", "Nama" }));
        pnSearchDiscPlg.add(cbSrcDiscPlg, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, 90, 20));

        infoDiscPlg.setFont(new java.awt.Font("Tahoma", 1, 14));
        infoDiscPlg.setForeground(new java.awt.Color(0, 0, 204));
        infoDiscPlg.setText("Search Data Diskon Pelanggan");
        pnSearchDiscPlg.add(infoDiscPlg, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 10, -1, 20));

        pnDiscPlg.add(pnSearchDiscPlg, java.awt.BorderLayout.PAGE_START);

        pnShow.add(pnDiscPlg, "discpelanggan");

        pnTengah.add(pnShow, java.awt.BorderLayout.CENTER);

        getContentPane().add(pnTengah, java.awt.BorderLayout.CENTER);

        setBounds(0, 0, 458, 404);
    }// </editor-fold>//GEN-END:initComponents

    private void formInternalFrameClosing(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosing
        // TODO add your handling code here:
        int clossing;
        clossing = JOptionPane.showConfirmDialog(this,
                "Tutup Pengaturan Discount Pelanggan?",
                "Konfirmasi",
                JOptionPane.YES_NO_OPTION);
        if (clossing == 0){
            this.dispose();
            FormMain.isfDPel = false;
        }
    }//GEN-LAST:event_formInternalFrameClosing

    private void btnDiscEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDiscEditActionPerformed
        // TODO add your handling code here:
        editData();        
}//GEN-LAST:event_btnDiscEditActionPerformed

    private void tbDiscPlgMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbDiscPlgMousePressed
        getDataFromDiscPlg();
}//GEN-LAST:event_tbDiscPlgMousePressed

    private void tbDiscPlgKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbDiscPlgKeyPressed
        // TODO add your handling code here:
        getDataFromDiscPlg();
}//GEN-LAST:event_tbDiscPlgKeyPressed

    private void tbDiscPlgKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbDiscPlgKeyReleased
        // TODO add your handling code here:
        getDataFromDiscPlg();
}//GEN-LAST:event_tbDiscPlgKeyReleased

    private void btnDiscSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDiscSearchActionPerformed
        // TODO add your handling code here:
        tampilSearchDiscPlg();
        btnDiscEdit.setEnabled(false);
}//GEN-LAST:event_btnDiscSearchActionPerformed

    private void btnDiscShowAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDiscShowAllActionPerformed
        // TODO add your handling code here:
        tampilDataDiscPlg();
}//GEN-LAST:event_btnDiscShowAllActionPerformed

    private void btnInfoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnInfoActionPerformed
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(this, "diskon ini akan mengurangi " +
                "total bayar pada saat transaksi","informasi",JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_btnInfoActionPerformed

    private void txtDiscPrsFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtDiscPrsFocusLost
        // TODO add your handling code here:
        if (!txtDiscPrs.getText().equals("0")){
            txtDiscRp.setText("0");
        }
    }//GEN-LAST:event_txtDiscPrsFocusLost

    private void txtDiscRpFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtDiscRpFocusLost
        // TODO add your handling code here:
        if (!txtDiscRp.getText().equals("0")){
            txtDiscPrs.setText("0");
        }
    }//GEN-LAST:event_txtDiscRpFocusLost

    private void txtDiscPrsKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDiscPrsKeyTyped
        // TODO add your handling code here:
        if (!txtDiscPrs.getText().equals("0")){
            txtDiscRp.setText("0");
        }
    }//GEN-LAST:event_txtDiscPrsKeyTyped

    private void txtDiscRpKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDiscRpKeyTyped
        // TODO add your handling code here:
        if (!txtDiscRp.getText().equals("0")){
            txtDiscPrs.setText("0");
        }
    }//GEN-LAST:event_txtDiscRpKeyTyped

    private void txtDiscPrsKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDiscPrsKeyPressed
        // TODO add your handling code here:
        if (!txtDiscPrs.getText().equals("0")){
            txtDiscRp.setText("0");
        }
    }//GEN-LAST:event_txtDiscPrsKeyPressed

    private void txtDiscRpKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDiscRpKeyPressed
        // TODO add your handling code here:
        if (!txtDiscRp.getText().equals("0")){
            txtDiscPrs.setText("0");
        }
    }//GEN-LAST:event_txtDiscRpKeyPressed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnDiscEdit;
    private javax.swing.JButton btnDiscSearch;
    private javax.swing.JButton btnDiscShowAll;
    private javax.swing.JButton btnInfo;
    private javax.swing.JComboBox cbSrcDiscPlg;
    private javax.swing.JCheckBox ckDiscBerlaku;
    private javax.swing.JLabel infoDiscPlg;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPanel pnAtas;
    private javax.swing.JPanel pnDiscPlg;
    private javax.swing.JPanel pnSearchDiscPlg;
    private javax.swing.JPanel pnShow;
    private javax.swing.JPanel pnTengah;
    private javax.swing.JScrollPane spDiscPlg;
    private javax.swing.JTable tbDiscPlg;
    private javax.swing.JTextField txtDiscPrs;
    private javax.swing.JTextField txtDiscRp;
    private javax.swing.JTextField txtKdPelanggan;
    private javax.swing.JTextArea txtKet;
    private javax.swing.JTextField txtNmPelanggan;
    private javax.swing.JTextField txtSrcDiscPlg;
    // End of variables declaration//GEN-END:variables


    private void kosongkan(){
        txtKdPelanggan.setText("");
        txtNmPelanggan.setText("");
        txtDiscPrs.setText("");
        txtDiscRp.setText("");
        txtKet.setText("");
        txtSrcDiscPlg.setText("");
        btnDiscEdit.setEnabled(false);
        btnDiscEdit.setText("Edit"); 
        ckDiscBerlaku.setSelected(false);
    }    
    private void tampilDataDiscPlg(){
        Object[] Baris={"Kode", "Nama", "Disc %", "Disc Rp"};
        DftTabModeDiscPlg=new DefaultTableModel(null,Baris);
        tbDiscPlg.setModel(DftTabModeDiscPlg);

        try {
            java.sql.Statement stmt = conn.createStatement();
            java.sql.ResultSet rslt = stmt.executeQuery("SELECT * FROM tplg");
            while (rslt.next()) {
                String sKdPlg = rslt.getString("kdPlg");
                String sNmPlg = rslt.getString("nmPlg");
                String sPrs = rslt.getString("disc_prs");
                String sRp = rslt.getString("disc_rp");

                String[] dataField = {sKdPlg, sNmPlg, sPrs, sRp};
                DftTabModeDiscPlg.addRow(dataField);
                int widths[] = {60, 270, 50, 100};
                for(int i=0;i<tbDiscPlg.getColumnCount();i++){
                    TableColumn column = tbDiscPlg.getColumnModel().getColumn(i);
                    column.setPreferredWidth(widths[i]);
                }
            }

        }
        catch(SQLException e) {
            System.out.println("gagal : " + e.toString());
        }
    }

    private void tampilSearchDiscPlg(){
        String srcby = "";
        if(cbSrcDiscPlg.getSelectedItem().toString().equals("Kode Disc")){
            srcby = "kdPlg";
        }else if(cbSrcDiscPlg.getSelectedItem().toString().equals("Nama")){
            srcby = "nmPlg";
        }

        Object[] Baris={"Kode","Nama", "Disc %", "Disc Rp"};
        DftTabModeDiscPlg=new DefaultTableModel(null,Baris);
        tbDiscPlg.setModel(DftTabModeDiscPlg);

        try {
            java.sql.Statement stmt = conn.createStatement();
            java.sql.ResultSet rslt = stmt.executeQuery(
                    "SELECT * FROM tplg WHERE " +
                    "AND UPPER(" + srcby +
                    ") like UPPER('%" +
                    txtSrcDiscPlg.getText() + "%')");
            while (rslt.next()) {
                String sKdPlg = rslt.getString("kdPlg");
                String sNmPlg = rslt.getString("nmPlg");
                String sDiscPrs = rslt.getString("disc_prs");
                String sDiscRp = rslt.getString("disc_rp");
                //String sNamaKota = rslt.getString("ket");

                String[] dataField = {sKdPlg, sNmPlg, sDiscPrs, sDiscRp};
                DftTabModeDiscPlg.addRow(dataField);
                int widths[] = {60, 270, 50, 100};
                for(int i=0;i<tbDiscPlg.getColumnCount();i++){
                    TableColumn column = tbDiscPlg.getColumnModel().getColumn(i);
                    column.setPreferredWidth(widths[i]);
                }
            }

        }
        catch(SQLException e) {
            System.out.println("gagal! : " + e.toString());
        }
    }

    private void editData(){         
        boolean selected = ckDiscBerlaku.isSelected();
        String berlaku = "";
        if (selected){
            berlaku ="1";
        }else{
            berlaku = "0";
        }
        try {
            PreparedStatement pStatement = null;
            String sql = "UPDATE tplg " +
                    "SET ket=?, " +
                    "disc_prs=?, disc_rp=?, " +
                    "berlaku=? " +
                    "WHERE kdPlg=? ";
            pStatement = conn.prepareStatement(sql);
            
            pStatement.setString(1, txtKet.getText());
            pStatement.setFloat(2, Float.parseFloat(txtDiscPrs.getText()));
            pStatement.setDouble(3, Double.parseDouble(txtDiscRp.getText()));
            pStatement.setString(4, berlaku);
            pStatement.setString(5, txtKdPelanggan.getText());

            int intTambah = pStatement.executeUpdate();
            if (intTambah >0){
                JOptionPane.showMessageDialog(this,
                        "Edit sukses", "Informasi",
                        JOptionPane.INFORMATION_MESSAGE);

            }else {
                JOptionPane.showMessageDialog(this,
                        "Edit gagal", "Informasi",
                        JOptionPane.INFORMATION_MESSAGE);
            }


            pStatement.close();
            kosongkan();
            tampilDataDiscPlg();


        } catch(SQLException e){
            System.out.println("koneksi gagal " + e.toString());
        }
    }
    private void getDataFromDiscPlg(){
                // TODO add your handling code here:
        Object oKdPlg, oNmPlg, oDiscPrs, oDiscRp;//, oTest;

        oKdPlg = tbDiscPlg.getValueAt(tbDiscPlg.getSelectedRow(), 0);
        oNmPlg = tbDiscPlg.getValueAt(tbDiscPlg.getSelectedRow(), 1);
        oDiscPrs = tbDiscPlg.getValueAt(tbDiscPlg.getSelectedRow(), 2);
        oDiscRp = tbDiscPlg.getValueAt(tbDiscPlg.getSelectedRow(), 3);

        try {
            java.sql.Statement stmt = conn.createStatement();
            java.sql.ResultSet rslt = stmt.executeQuery("SELECT * " +
                    "FROM tplg WHERE " +
                    "kdPlg=" +
                    "'" +oKdPlg+ "'");
            while (rslt.next()) {                
                txtKet.setText(rslt.getString("ket"));

                if(rslt.getString("berlaku").toString().equals("1")){
                    ckDiscBerlaku.setSelected(true);
                }else{
                    ckDiscBerlaku.setSelected(false);
                }
            }

        }
        catch(SQLException e) {
            System.out.println("gagal : " + e.toString());
        }

        /*
        if(oTest == null){
            oTest = " ";
        }
         *
         */

        txtKdPelanggan.setText(oKdPlg.toString());
        txtNmPelanggan.setText(oNmPlg.toString());
        txtDiscPrs.setText(oDiscPrs.toString());
        txtDiscRp.setText(oDiscRp.toString());

        btnDiscEdit.setEnabled(true);        
    }
}
